<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Candy - Chats are not dead yet</title>
	<link rel="shortcut icon" href="../res/img/favicon.png" type="image/gif" />

	<link rel="stylesheet" type="text/css" href="../res/default.css" />
	<link rel="stylesheet" type="text/css" href="../plugins/colors/candy.css" />
	<link rel="stylesheet" type="text/css" href="../plugins/roomPanel/default.css" />
	<link rel="stylesheet" type="text/css" href="../plugins/timeago/candy.css" />
	<link rel="stylesheet" type="text/css" href="../plugins/videobridge/candy.css" />

	<script type="text/javascript" src="../libs/jquery.min.js"></script>
	<script type="text/javascript" src="../libs/libs.min.js"></script>
	<script type="text/javascript" src="../libs/strophe-connection-websockets.js"></script>
	<script type="text/javascript" src="../libs/candy.bundle.js"></script>
	<script type="text/javascript" src="../plugins/colors/candy.js"></script>
	<script type="text/javascript" src="../plugins/roomPanel/roomPanel.js"></script>
	<script type="text/javascript" src="../plugins/timeago/candy.js"></script>
	<script type="text/javascript" src="../plugins/videobridge/candy.js"></script>
	<script type="text/javascript" src="../plugins/videobridge/jingle.sdp.js"></script>
	<script type="text/javascript" src="../plugins/fastpath/candy.js"></script>

	<script type="text/javascript">

    	function urlParam(name)
    	{
			var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
			if (!results) { return undefined; }
			return results[1] || undefined;
    	};

		function toggleFullScreen()
		{
			var videoElement = document.getElementById("largeVideo");

			if (!document.mozFullScreen && !document.webkitFullScreen)
			{
			  if (videoElement.mozRequestFullScreen) {
				videoElement.mozRequestFullScreen();

			  } else {
				videoElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
			  }

			} else {

			  if (document.mozCancelFullScreen) {
				document.mozCancelFullScreen();
			  } else {
				document.webkitCancelFullScreen();
			  }
			}
		}

		$(document).ready(function() {
			Candy.init('/http-bind/', {
				core: { debug: false, websockets: true},
				view: { resources: '../res/' }
			});

			var username = urlParam("username");
			var password = urlParam("password");

			CandyShop.RoomPanel.init({
				// domain that hosts the muc rooms, only required if autoDetectRooms is enabled
				mucDomain: 'conference.' + window.location.hostname,

				// show room list if all rooms are closed, default value is true. [optional]
				showIfAllTabClosed: true,

				// detect rooms before showing list, default value is true. [optional]
				autoDetectRooms: true,

				// how long in seconds before refreshing room list, default value is 600. [optional]
				roomCacheTime: 600
			});

			CandyShop.Colors.init();
			CandyShop.Timeago.init();
			CandyShop.Videobridge.init();
			CandyShop.Fastpath.init();

			if (username)
				Candy.Core.connect(username + "@" + window.location.hostname, password, username);
			else
				Candy.Core.connect();

		});
	</script>
</head>
<body>
    <div class="fade_line"></div>
	<div id="candy"></div>
    <div class="fade_line"></div>
	<video  id="largeVideo" onDblClick="toggleFullScreen();" autoplay oncontextmenu="return false;"></video>
	<div id="remoteVideos">
	<video id="localVideo" autoplay oncontextmenu="return false;" muted/>
    </div>
</body>
</html>
